package com.hl.sfzy.controller;

import com.hl.sfzy.entity.Fm;
import com.hl.sfzy.entity.Knowledge;
import com.hl.sfzy.entity.Problem;
import com.hl.sfzy.service.FmService;
import com.hl.sfzy.service.KnowledgeService;
import com.hl.sfzy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName FmController
 * @Description TODO
 * @Author Jerry
 * @Date 2024年01月13日 10:47
 * @Version 1.0
 */
@CrossOrigin
@RestController
@RequestMapping({"/fm"})
public class FmController {
    @Autowired
    private FmService FmService;
    @PostMapping("/add")
    public Result add(@RequestBody Fm fm) throws Exception {
        this.FmService.add(fm);
        return Result.success();
    }
    /**
     * 编辑
     */
    @PutMapping("/edit")
    public Result edit(@RequestBody Fm fm) {
        FmService.edit(fm);
        return Result.success();
    }
    /**
     * 删除
     */
    @DeleteMapping("/remove/{id}")
    public Result remove(@PathVariable Integer id) {
        FmService.remove(id);
        return Result.success();
    }
    /**
     * 批量删除
     */
    @DeleteMapping("/remove")
    public Result removeBatch(Integer[] ids) {
        System.out.println(ids);
        FmService.removeBatch(ids);
        return Result.success();
    }
    @GetMapping({"/find"})
    public Result findPage(@RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize, Fm fm) {
        System.out.println(fm);
        return Result.success(this.FmService.findPage(pageNum, pageSize, fm));
    }


}
